const App = {
  mixins: [Save], //配置文件，路径/utils/mixins.js
  data() {
    return {
      dhCoord: "",
      loading2: false,
      loading: false,
      dataForm: {
        Coords: "",
        Unit_Quantity: "",
        Layer_Quantity: "",
        Room_Quantity: "",
        Introduce: "",
      },
      blue_plate_house_tags: [],
      tableData: [],
      treeData: [],
      Grid: [],
      house_type: [],
      Sortable: null,
      personal: [],
      relation: [],
      childDataForm1: [],
      childDataForm3: [{}],
      natural_resources_management: [],
      cityValue: ["230000", "232700", "232723"],
      cityValue1: [],
      city: [],
      city1: [],
      image_type: [],
      drag: false,
      village_collective: [],
      is: true,
      showDialog: false,
      isQuery: false,
      value: "",
      isupdata: true,
      value1: [],
      value2: [],
      value3: [],
      base_system_village: [],
      personal_information: [],
      blue_plate_self_built_house_type: [],
      blue_plate_type: []
    };
  },
  mounted() {
    this.getCategory();
    this.getCity();
    if (this.action == "Add") {
      this.changeCity(this.cityValue);
    }
    // this.$nextTick(() => {
    //   //拖拽排序
    //   var $ul = document.querySelector("#ChildTable #form1");
    //   $ul.addEventListener("selectstart", function (e) {
    //     e.preventDefault();
    //   });
    //   this.Sortable = Sortable.create($ul, {
    //     handle: ".el-descriptions",
    //     draggable: ".el-descriptions",
    //     animation: 150,
    //     onUpdate: (event) => {
    //       let newIndex = event.newIndex, oldIndex = event.oldIndex;
    //       ($li = $ul.children[newIndex]), ($oldLi = $ul.children[oldIndex]);
    //       //先删除移动的节点, 再插入移动的节点到原有节点，还原了移动的操作
    //       $ul.removeChild($li);
    //       if (newIndex > oldIndex) {
    //         $ul.insertBefore($li, $oldLi);
    //       } else {
    //         $ul.insertBefore($li, $oldLi.nextSibling);
    //       }
    //       //通过改变vue遍历数组移动节点
    //       let item = this.childDataForm[oldIndex];
    //       this.childDataForm.splice(oldIndex, 1);
    //       this.childDataForm.splice(newIndex, 0, item);
    //     },
    //   });
    //   this.Sortable.option('disabled', !this.drag);
    // });
  },
  watch: {
    "dataForm.Village_SerialNumber"(val) {
      if (this.action == "Modify" && this.is) {
        this.is = false;
        let str = this.dataForm.Village_SerialNumber;
        if (str.substring(0, 6)) {
          $.ajax({
            headers: requestHeaders(),
            url: `${mh}/permissionsTree/getDistrictTreeByPermissions`,
            type: "GET",
            data: {
              DistrictCode: getCookie('village'),

            },
            success: (data) => {
              // data[0].children.forEach((item) => {
              //   item.children = undefined;
              // });
              this.city1 = data[0].children;
              if (str.length != 9) {
                this.cityValue1 = [str.substring(0, 9), str];
              } else {
                this.cityValue1 = [str];
              }
              this.cityValue = [
                str.substring(0, 2) + "0000",
                str.substring(0, 4) + "00",
                str.substring(0, 6),
              ];
            },
            complete: (XMLHttpRequest) => {
              requestPretreatment(XMLHttpRequest);
            },
            dataType: "json",
          });
        }
        $.ajax({
          headers: requestHeaders(),
          url: `${mh}/generalBusiness/generalQueryByTableName`,
          type: "POST",
          data: {
            Data: "blue_plate_house_tags",
            Condition: "Row_Status='0' AND Parent_SerialNumber<>''",
          },
          success: (data) => {
            let value1 = [],
              value2 = [],
              value3 = [];
            this.childDataForm1
              .filter((i) => i.Row_Status != "1")
              .forEach((item) => {
                let obj = data.filter(
                  (i) =>
                    i.Blue_Plate_House_Tag_SerialNumber ==
                    item.Blue_Plate_House_Tag_SerialNumber
                )[0];
                if (obj) {
                  if (obj.Parent_SerialNumber == "BPHT00000000001") {
                    value2.push(item.Blue_Plate_House_Tag_SerialNumber);
                  } else if (obj.Parent_SerialNumber == "BPHT00000000002") {
                    value3.push(item.Blue_Plate_House_Tag_SerialNumber);
                  } else if (obj.Parent_SerialNumber == "BPHT00000000003") {
                    value1.push(item.Blue_Plate_House_Tag_SerialNumber);
                  }
                }
              });
            this.value1 = value1;
            this.value2 = value2;
            this.value3 = value3;
          },
          complete: (XMLHttpRequest) => {
            requestPretreatment(XMLHttpRequest);
          },
          dataType: "json",
        });
      }
    },
    "dataForm.Address": {
      handler(newVal, oldVal) {
        console.log("地址值变化了:", newVal);

        // 这里可以添加地址变化时的处理逻辑
        // 例如：自动更新坐标
        // map.clearOverlays();

        // 重置全局坐标点（解决多次搜索时的坐标残留问题）
        bd09Point = null;
      },
      deep: false, // 不需要深度监听，因为Address是基本类型
      immediate: false, // 是否在初始化时立即执行一次
    },
    // 新增：监听 dataForm.Coord 的变化
    "dataForm.Coord": {
      handler(newVal, oldVal) {
        console.log("坐标值变化了:", newVal);

        // 防止空值或无效值导致错误
        if (!newVal || newVal === "[]") return;

        try {
          // 解析坐标值
          const values = JSON.parse(newVal);
          const lng = values[0];
          const lat = values[1];

          // 检查地图对象是否存在
          if (window.map) {
            // 更新地图中心点
            window.map.centerAndZoom(
              new window.TLngLat(lng, lat),
              window.zoom || 12
            );

            // 更新或创建标注
            if (window.marker) {
              window.map.removeOverLay(window.marker);
            }
            window.marker = new window.TMarker(new window.TLngLat(lng, lat));
            window.map.addOverLay(window.marker);

            console.log("地图已更新到坐标:", lng, lat);
          } else {
            console.warn("地图对象未初始化，请确保 onLoad 函数已执行");
          }
        } catch (error) {
          console.error("坐标解析失败:", error);
        }
      },
      deep: false,
      immediate: true, // 初始化时立即执行一次，确保页面加载时地图显示正确
    },
  },
  computed: {
    RoomNumbers() {
      const { Unit_Quantity, Layer_Quantity, Room_Quantity } = this.dataForm;
      if (
        !isNaN(Unit_Quantity) &&
        !isNaN(Layer_Quantity) &&
        !isNaN(Room_Quantity)
      ) {
        let arr = [];
        for (let i = 1; i <= Number(Unit_Quantity); i++) {
          for (let j = 1; j <= Number(Layer_Quantity); j++) {
            for (let z = 1; z <= Number(Room_Quantity); z++) {
              arr.push({
                Blue_Plate_SerialNumber: this.dataForm.Blue_Plate_SerialNumber,
                Unit_Number: i,
                Layer_Number: j,
                Room_Number: z,
                Room_SerialNumber:
                  i + "-" + (j < 10 ? "0" + j : j) + (z < 10 ? "0" + z : z),
              });
            }
          }
        }
        return arr;
      }
      return [];
    },
    Agensies_Name() {
      return function (str) {
        let obj = this.blue_plate_house_tags.filter(
          (i) => i.Blue_Plate_House_Tag_SerialNumber == str
        )[0];
        if (obj) {
          return obj.Blue_Plate_House_Tag;
        }
        return "";
      };
    },
  },
  methods: {
    InputBlue_Plate_Name(val) {
      if (this.dataForm.Self_Built_Houses == "1") {
        this.childDataForm3[0].Self_Built_House_Name = val;
      }
    },
    changeSwitch(val) {
      if (val == "1") {
        this.childDataForm3[0].Self_Built_House_Name =
          this.dataForm.Blue_Plate_Name;
      } else {
        this.childDataForm3[0] = {};
      }
    },
    handledrag() {
      this.drag = !this.drag;
      this.Sortable.option("disabled", !this.drag);
    },
    PerName(val) {
      const _this = this;
      console.log(val);
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/generalBusiness/generalQueryByTableName`,
        type: "POST",
        data: {
          Data: "personal_information",
          Condition: "ID_Card_Number='" + val + "'",
        },
        success: (data) => {
          _this.dataForm.Contact_Phone = data[0].Contact_Phone;
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
        dataType: "json",
      });
    },
    changeCity1(val) {
      console.log(val);
      if (val.length > 0) {
        this.dataForm.Town_Number = val[0];
        this.dataForm.Village_SerialNumber = val[val.length - 1];
        if (this.dataForm.Address) {
          this.changeAddress(this.dataForm.Address);
        }
        // $.ajax({
        //   url: `${mh}/generalBusiness/generalQueryByTableName`,
        //   type: "POST",
        //   data: {
        //     Data: val.length==1?"base_system_town":"base_system_village_collective",
        //     Condition: (val.length==1?"TownNumber":"VillageNumber") + " = '" + val[val.length-1] + "'",
        //   },
        //   success: (data) => {
        //     console.log(data);

        //     this.village_collective = data; // 直接使用 this
        //   },
        //   dataType: "json",
        // });
      } else {
        this.dataForm.Village_SerialNumber = "";
      }
    },
    changeCity(val) {
      if (val.length > 0) {
        this.dataForm.Province_Number = val[0];
        this.dataForm.City_Number = val[1];
        this.dataForm.County_Nubmer = val[2];
        $.ajax({
          headers: requestHeaders(),
          url: `${mh}/clientOperation/getDistrictTree`,
          type: "GET",
          data: {
            DistrictCode: val[2],
          },
          success: (data) => {
            this.city1 = data[0].children;
            console.log(this.city1);
          },
          complete: (XMLHttpRequest) => {
            requestPretreatment(XMLHttpRequest);
          },
          dataType: "json",
        });
        // $.ajax({
        //   headers: requestHeaders(),
        //   url: `${mh}/permissionsTree/getDistrictTreeByPermissions`,
        //   type: "GET",
        //   data: {
        //     DistrictCode: getCookie('village'),

        //   },
        //   success: (data) => {
        //     // data[0].children.forEach((item) => {
        //     //   item.children = undefined;
        //     // });

        //     this.city1 = data[0].children;
        //   },
        //   complete: (XMLHttpRequest) => {
        //     requestPretreatment(XMLHttpRequest);
        //   },
        //   dataType: "json",
        // });
      }
    },
    getCity() {
      $.ajax({
        url: `${absolutepath()}api/Districtjl.json`,
        method: "get",
        success: (data) => {
          data.forEach((item) => {
            item.children.forEach((ite) => {
              ite.children.forEach((it) => {
                it.children = undefined;
              });
            });
          });
          this.city = data;
        },
      });
    },
    changeAddress(val) {
      console.log("地址值变化了:", val);
      if (!val || this.cityValue1.length === 0) {
        this.dataForm.Coord = "";
        return;
      }
      // 开始加载状态
      this.loading = true;
      console.log("地址值变化，开始解析坐标...");

      let Province = this.city.filter((i) => i.value == this.cityValue[0])[0];
      let City = Province.children.filter(
        (i) => i.value == this.cityValue[1]
      )[0];
      let County = City.children.filter((i) => i.value == this.cityValue[2])[0];
      let Town = this.city1.filter(
        (i) => i.ProvinceNumber == this.cityValue1[0]
      )[0];
      // let village = Town.children.filter(
      //   (i) => i.ProvinceNumber == this.cityValue1[1]
      // )[0];
      let Address =
        Province.label +
        City.label +
        County.label +
        Town.Province +
        // village.Province +
        val;
      if (Address) {
        $.ajax({
          url: `${y}/getAddressResolutionAction`,
          type: "get",
          data: {
            Address: Address,
          },
          success: (data) => {
            console.log(data);
            console.log(data.Data);
            console.log(Address);
            // return;
            // localSearch.setSearchCompleteCallback((searchResult) => {
            var poi = data.Data;
            console.log(poi);

            let a = poi.lng + "," + poi.lat;
            console.log(a);

            if (a) {
              console.log(a);

              // 获取BD-09坐标
              const bd09Lng = poi.lng;
              const bd09Lat = poi.lat;

              // 转换为WGS-84坐标
              const wgs84 = bd09ToWGS84(bd09Lng, bd09Lat);
              console.log(wgs84);
              // 腾讯2000
              const gcj02 = bd09ToGCJ02(bd09Lng, bd09Lat);
              console.log(gcj02);
              this.dataForm.dhCoord = "[" + gcj02.lng + "," + gcj02.lat + "]";

              this.dataForm.Coord = "[" + wgs84.lng + "," + wgs84.lat + "]";
              console.log(this.dataForm.Coord);
              this.loading = false;
            } else {
              alert("未找到该地址！");
            }
          },

          dataType: "json",
        });
      }
    },
    getCategory() {
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/generalBusiness/generalQueryByTableName`,
        type: "POST",
        data: {
          Data: "grid_information",
          Condition: "Row_Status='0'",
        },
        success: (data) => {
          this.Grid = data; // 直接使用 this
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
        dataType: "json",
      });
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/generalBusiness/generalQueryByTableName`,
        type: "POST",
        data: {
          Data: "blue_plate_type",
          Condition: "Row_Status='0'",
        },
        success: (data) => {
          this.blue_plate_type = data; // 直接使用 this
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
        dataType: "json",
      });
      $.ajax({
        headers: requestHeaders(),

        url: `${mh}/generalBusiness/generalQueryByTableName`,
        type: "POST",
        data: {
          Data: "natural_resources_management",
          Condition: "Row_Status='0'",
        },
        success: (data) => {
          this.natural_resources_management = data; // 直接使用 this
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
        dataType: "json",
      });
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/generalBusiness/generalQueryByTableName`,
        type: "POST",
        data: {
          Data: "personal_information",
          Condition: "Row_Status='0' and RR_Village_Number in (" + getCookie('village') + ")",
        },
        success: (data) => {
          console.log(data);
          this.personal = data; // 直接使用 this
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
        dataType: "json",
      });
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/generalBusiness/generalQueryByTableName`,
        type: "POST",
        data: {
          Data: "blue_plate_house_type",
          Condition: "Row_Status='0'",
        },
        success: (data) => {
          this.house_type = data; // 直接使用 this
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
        dataType: "json",
      });
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/generalBusiness/generalQueryByTableName`,
        type: "POST",
        data: {
          Data: "relation_type",
          Condition: "Row_Status='0'",
        },
        success: (data) => {
          this.relation = data; // 直接使用 this
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
        dataType: "json",
      });
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/generalBusiness/generalQueryByTableName`,
        type: "POST",
        data: {
          Data: "image_type",
          Condition: "Row_Status='0'",
        },
        success: (data) => {
          this.image_type = data; // 直接使用 this
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
        dataType: "json",
      });
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/generalBusiness/generalQueryForObtainingTrees`,
        type: "GET",
        data: {
          TableName: "blue_plate_house_tags",
          NodeCode: "",
        },
        success: (data) => {
          this.treeData = data; // 直接使用 this
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
        dataType: "json",
      });
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/generalBusiness/generalQueryByTableName`,
        type: "POST",
        data: {
          Data: "blue_plate_house_tags",
          Condition: "Row_Status='0' AND Parent_SerialNumber<>''",
        },
        success: (data) => {
          this.blue_plate_house_tags = data; // 直接使用 this
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
        dataType: "json",
      });
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/generalBusiness/generalQueryByTableName`,
        type: "POST",
        data: {
          Data: "base_system_village",
          Condition: "VillageNumber LIKE '232723%'",
        },
        success: (data) => {
          this.base_system_village = data;
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
        dataType: "json",
      });
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/generalBusiness/generalQueryByTableName`,
        type: "POST",
        data: {
          Data: "personal_information",
          Condition: "Row_Status='0'",
        },
        success: (data) => {
          this.personal_information = data;
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
        dataType: "json",
      });
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/generalBusiness/generalQueryByTableName`,
        type: "POST",
        data: {
          Data: "blue_plate_self_built_house_type",
          Condition: "Row_Status='0'",
        },
        success: (data) => {
          console.log(data);
          this.blue_plate_self_built_house_type = data;
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
        dataType: "json",
      });
    },
    getData(nodeKey) {
      //查询
      const that = this;
      //获取对应子表表单对象
      let lJSONObject_Children = new Array();
      let lJSONObject_ChildData = new Object();
      try {
        //可能涉及多个子表
        document
          .getElementById("ChildTable")
          .querySelectorAll(".el-descriptions")
          .forEach((item) => {
            let lJSONObject_ChildData_Options = new Object();
            lJSONObject_ChildData_Options = JSON.parse(
              item.getAttribute("data-options")
            );

            let ls_ChildTableName = lJSONObject_ChildData_Options.TableName;
            let ls_ChildDataForm = lJSONObject_ChildData_Options.form;

            lJSONObject_ChildData[ls_ChildTableName] = ls_ChildDataForm;
            lJSONObject_Children[ls_ChildTableName] = "ChildTable";
          });
      } catch (error) { }
      //获得对应表单对象
      let lJSONObject_Data_Options = new Object();
      lJSONObject_Data_Options = JSON.parse(
        document.getElementById("MainTable").getAttribute("data-options")
      );
      let ls_DataForm = lJSONObject_Data_Options.form;
      let ls_TableName = lJSONObject_Data_Options.TableName;
      let ls_primary_key = lJSONObject_Data_Options.primary_key;

      let lJSONObject_Data = new Object();
      lJSONObject_Data[ls_TableName] = ls_DataForm;
      lJSONObject_Data = { ...lJSONObject_Data, ...lJSONObject_ChildData };

      let lJSONObject_TableName = new Object();
      lJSONObject_TableName[ls_TableName] = "MainTable";
      lJSONObject_TableName = {
        ...lJSONObject_TableName,
        ...lJSONObject_ChildData,
      };
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/generalBusiness/generalQueryByTableNameWithOriginal`,
        method: "post",
        data: {
          Data: "blue_plate_information",
          Condition: `${ls_primary_key}='${nodeKey}'`,
        },
        success: (res) => {
          that.dataForm = res[0];
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
      });
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/generalBusiness/generalQueryByTableNameWithOriginal`,
        method: "post",
        data: {
          Data: "blue_plate_image",
          Condition: `${ls_primary_key}='${nodeKey}'
          ORDER BY Image_Order+0`,
        },
        success: (res) => {
          that.childDataForm = res;
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
      });
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/generalBusiness/generalQueryByTableNameWithOriginal`,
        method: "post",
        data: {
          Data: "blue_plate_house_mapping_tags",
          Condition: `${ls_primary_key}='${nodeKey}'`,
        },
        success: (res) => {
          that.childDataForm1 = res;
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
      });
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/generalBusiness/generalQueryByTableNameWithOriginal`,
        method: "post",
        data: {
          Data: "blue_plate_self_built_house",
          Condition: `${ls_primary_key}='${nodeKey}'`,
        },
        success: (res) => {
          that.childDataForm3 = res;
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
      });
    },
    handleNodeClick(data) {
      if (!data.children || children.length == 0) {
        let obj = this.childDataForm1.filter(
          (i) =>
            i.Blue_Plate_House_Tag_SerialNumber ==
            data.Blue_Plate_House_Tag_SerialNumber
        )[0];
        if (!obj) {
          this.childDataForm1.push({
            Blue_Plate_SerialNumber: this.dataForm.Blue_Plate_SerialNumber,
            Blue_Plate_House_Tag_SerialNumber:
              data.Blue_Plate_House_Tag_SerialNumber,
          });
          this.$nextTick(() => {
            this.isupdata = !this.isupdata;
          });
        } else {
          obj.Row_Status = "0";
        }
      }
    },
    InputCoords(val) {
      this.dataForm.Coords = val.replace(/\s+/g, '');
    },
    remove(item) {
      if (Object.keys(item).some((item) => item.includes("_Original"))) {
        this.childDataForm1.filter(
          (i) =>
            i.Blue_Plate_House_Tag_SerialNumber ==
            item.Blue_Plate_House_Tag_SerialNumber
        )[0].Row_Status = "1";
      } else {
        this.childDataForm1 = this.childDataForm1.filter(
          (i) =>
            i.Blue_Plate_House_Tag_SerialNumber !=
            item.Blue_Plate_House_Tag_SerialNumber
        );
      }
    },
    clear() {
      if (this.action == "Add") {
        this.childDataForm1 = [];
      } else {
        this.childDataForm1.forEach((item) => {
          if (Object.keys(item).some((item) => item.includes("_Original"))) {
            this.childDataForm1.filter(
              (i) =>
                i.Blue_Plate_House_Tag_SerialNumber ==
                item.Blue_Plate_House_Tag_SerialNumber
            )[0].Row_Status = "1";
          } else {
            this.childDataForm1 = this.childDataForm1.filter(
              (i) =>
                i.Blue_Plate_House_Tag_SerialNumber !=
                item.Blue_Plate_House_Tag_SerialNumber
            );
          }
        });
      }
    },
    query(val) {
      if (val) {
        $.ajax({
          headers: requestHeaders(),
          url: `${mh}/generalBusiness/generalQueryByTableName`,
          type: "POST",
          data: {
            Data: "blue_plate_house_tags",
            Condition:
              "Row_Status='0' AND Blue_Plate_House_Tag LIKE '%" +
              val +
              "%' AND Parent_SerialNumber <> ''",
          },
          success: (data) => {
            this.isQuery = true;
            this.tableData = data; // 直接使用 this
          },
          complete: (XMLHttpRequest) => {
            requestPretreatment(XMLHttpRequest);
          },
          dataType: "json",
        });
      } else {
        this.isQuery = false;
        this.tableData = [];
      }
    },
    async handleSubmit() {
      const allValid = await this.validateAllForms();
      if (allValid) {
        this.loading2 = true;
        this.childDataForm
          .filter((i) => i.Row_Status != "1")
          .forEach((item, index) => {
            item.Image_Order = index + 1;
          });

        let ls_URL = window.location.href;
        const action = getQueryObject(ls_URL, "action"); // 获取 action 参数
        let lJSONObject_Data_Options = new Object();
        lJSONObject_Data_Options = JSON.parse(
          document.getElementById("MainTable").getAttribute("data-options")
        );

        let ls_MainTableName = lJSONObject_Data_Options.TableName;
        let ls_DataForm = lJSONObject_Data_Options.form;
        let ls_primary_key = lJSONObject_Data_Options.primary_key;
        //没有子表下面内容就会报错，try/catch抛出异常
        if (action == "Add") {
          [...this.value1, ...this.value2, ...this.value3].forEach((item) => {
            this.childDataForm1.push({
              Blue_Plate_House_Tag_SerialNumber: item,
            });
          });
        } else if (action == "Modify") {
          let arr = [...this.value1, ...this.value2, ...this.value3];
          arr.forEach((item) => {
            let obj = this.childDataForm1.filter(
              (i) => i.Blue_Plate_House_Tag_SerialNumber == item
            )[0];
            if (obj) {
              obj.Row_Status = "0";
            } else {
              this.childDataForm1.push({
                Blue_Plate_SerialNumber: this.dataForm.Blue_Plate_SerialNumber,
                Blue_Plate_House_Tag_SerialNumber: item,
              });
            }
          });
          this.childDataForm1.forEach((item) => {
            if (!arr.some((i) => i == item.Blue_Plate_House_Tag_SerialNumber)) {
              item.Row_Status = "1";
            }
          });
        }
        try {
          //可能涉及多个子表
          document
            .getElementById("ChildTable")
            .querySelectorAll(".el-descriptions")
            .forEach((item) => {
              if (item.hasAttribute("data-options")) {
                let lJSONObject_ChildData_Options = new Object();
                lJSONObject_ChildData_Options = JSON.parse(
                  item.getAttribute("data-options")
                );

                let ls_ChildTableName = lJSONObject_ChildData_Options.TableName;
                let ls_ChildDataForm = lJSONObject_ChildData_Options.form;
                // let ls_ParentTableName = lJSONObject_ChildData_Options.ParentTableName;
                if (this[ls_DataForm][ls_primary_key]) {
                  this[ls_ChildDataForm].forEach((item) => {
                    item[ls_primary_key] = this[ls_DataForm][ls_primary_key];
                  });
                }
                //建立子表结构体
                let JSONArray_ChildRecord = new Array();
                JSONArray_ChildRecord = this[ls_ChildDataForm];
                if (!this[ls_DataForm].Children) {
                  this[ls_DataForm].Children = new Object();
                }
                this[ls_DataForm].Children[ls_ChildTableName] =
                  JSONArray_ChildRecord;
              }
            });
        } catch (error) { }

        //建立新增提交结构
        let lJSONObject_DataSet = new Object();
        if (action == "Add") {
          if (this.nodeKey) {
            this[ls_DataForm].Parent_SerialNumber = this.nodeKey;
          }
          let lJSONArray_Record = new Array();
          lJSONArray_Record.push(this[ls_DataForm]);
          let lJSONObject_Table = new Object();
          lJSONObject_Table[ls_MainTableName] = lJSONArray_Record;
          lJSONObject_DataSet[action] = lJSONObject_Table;
        } else if (action == "Modify") {
          const { add, modify } = this.deal(this[ls_DataForm]);
          let lJSONArray_Record = new Array();
          lJSONArray_Record.push(modify);

          let lJSONObject_Table = new Object();
          lJSONObject_Table[ls_MainTableName] = lJSONArray_Record;

          let lJSONObject_Table_Add = new Object();
          lJSONObject_DataSet[action] = lJSONObject_Table;
          if (
            this.dataForm.Responsible_Person !=
            this.dataForm.Responsible_Person_Original
          ) {
            let blue_plate_house_unit = [
              {
                Blue_Plate_SerialNumber: this.dataForm.Blue_Plate_SerialNumber,
                Blue_Plate_Personal_SerialNumber:
                  this.dataForm.Responsible_Person,
                Personal_SerialNumber:
                  this.dataForm.Responsible_Person_Original,
              },
            ];
            lJSONObject_Table_Add["grid_blue_plate_log"] =
              blue_plate_house_unit;
          }
          if (add != null) {
            let lJSONArray_Record_Add = new Array();
            lJSONArray_Record_Add.push(add);
            lJSONObject_Table_Add[ls_MainTableName] = lJSONArray_Record_Add;
          }
          lJSONObject_DataSet["Add"] = lJSONObject_Table_Add;
        }
        let Operation_Main = JSON.stringify(deepClone(lJSONObject_DataSet));
        if (!lJSONObject_DataSet["Add"]) {
          lJSONObject_DataSet["Add"] = new Object();
        }
        lJSONObject_DataSet["Add"]["base_operation_log"] = [
          {
            Operation_Type: "0",
            Operation_Path: this.relativePath,
            Operation_Main,
            Operation_Interface: "generalSaveByRequestBody",
            Operation_IP: getIpAddress(),
          },
        ];
        submitSave(lJSONObject_DataSet, (res) => {
          if (res.Status == 'success') {
            window.history.go(-1);
          }
          this.loading = false;
        })
        // $.ajax({
        //   headers: requestHeaders("JSON"),
        //   url: `${mh}/generalBusiness/generalSaveByRequestBody`,
        //   method: "post",
        //   data: JSON.stringify({
        //     Data: lJSONObject_DataSet,
        //   }),
        //   success: (res) => {
        //     if (res.Status == "success") {
        //       // window.location.href = "./index.html";
        //       window.history.go(-1);
        //     }
        //   },
        //   complete: (XMLHttpRequest) => {
        //     requestPretreatment(XMLHttpRequest);
        //   },
        // });
      }
    },
  },
};
const { createApp, ref } = Vue;
const app = createApp(App);
app.use(ElementPlus, { locale: zhCn });
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}
app.component("yl-upload", ylUpload);
app.component("yl-cascader", ylCascader);
app.component('yl-select', ylSelect)
app.component("yl-text-editor", ylTextEditor);
const ElMessage = ElementPlus.ElMessage;
app.mount("#app");
